import math

def is_simple(a):
    for i in range(2, int(a / 2) + 1):
        if a % i == 0:
            return False
    return True

def get_next_s(a):
    while not is_simple(a):
        a += 1
    return a

def get_before_s(a):
    while not is_simple(a):
        a -= 1
    return a

input_str = input()
a = input_str.split()

if len(a) <= 2:
    print("Wrong input")
else:
    c = []
    for i in a:
        if i == "one":
            c.append('1')
        elif i == "two":
            c.append('2')
        elif i == "three":
            c.append('3')
        elif i == "four":
            c.append('4')
        elif i == "five":
            c.append('5')
        elif i == "six":
            c.append('6')
        elif i == "seven":
            c.append('7')
        elif i == "eight":
            c.append('8')
        elif i == "nine":
            c.append('9')
        elif i == "zero":
            c.append('0')
    e = ''.join(c)
    r = int(e)
    d = get_before_s(r)
    x = get_next_s(r)
    if abs(d - r) < abs(x - r):
        print(d)
    else:
        print(x)

